const app = getApp()
Page({
  data: {
    store: [],
    checked: true
  },
  //监听页面显示
  onLoad: function () {
    let that = this;
    app.isLogin(function () {
      that.getApi();
    });
  },
  //监听页面初次渲染完成
  onReady: function () {
    this.setData({
      skeleton: false,
    })
  },
  //读取我的订单
  getApi: function () {
    let that = this;
    let checked = false;
    app.api().Get("api/v1/allwin-store-manage", function (result) {
      checked = result.data.state == 1 ? true : false;
      that.setData({
        store: result.data,
        checked: checked
      });
    })
  },
  //修改安全状态
  onChange(event) {
    let that = this;
    that.setData({checked:event.detail});
    app.api().Post('api/v1/allwin-store-editState', {
        state: event.detail,
      }, function (res){})
  },
  //点击预览
  openView: function (e) {
    var id = e.currentTarget.id;
    wx.navigateTo({
      url: 'edit?store_id=' + id
    })
  },
  //其他服务
  other: function (e) {
    let that = this;
    var id = e.currentTarget.dataset.id;
    var config = wx.getStorageSync('config');
    wx.navigateTo({
      url: '/pages/helper/webview?src=' + app.apiroot + '/wechat-' + config.app_id + '/allwin-store-service/' + id,
    })
  },
})